package org.icec.web.sys.service;


import org.beetl.sql.core.engine.PageQuery;
import org.icec.web.sys.dao.SysClientAccountDao;
import org.icec.web.sys.model.SysClientAccount;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/*
* 
* gen by 阚文杰  2017-11-01
*/
@Service
public class SysClientAccountService {
	@Autowired
	private SysClientAccountDao sysClientAccountDao;


	/**
	 * 客户分页查询
	 * @param query
	 * @return
	 */
	public PageQuery<SysClientAccount> queryClientAccount(PageQuery<SysClientAccount> query) {
		return sysClientAccountDao.findAccountByClientNo(query);
	}


	/**
	 *
	 *保存
	 */
	@Transactional
	public void saveAccount(SysClientAccount sysClientAccount){
		sysClientAccount.setInsertdate(new Date());
		sysClientAccount.setDel_flag(0);
		sysClientAccountDao.insert(sysClientAccount);
	}



	public SysClientAccount findById(Integer id) {
		return sysClientAccountDao.findById(id);
	}



	/**
	 * 更新操作，更新del_flag字段
	 *
	 * @param
	 */
	@Transactional
	public void update(SysClientAccount sysClientAccount) {
		sysClientAccountDao.updateTemplateById(sysClientAccount);
	}



	/**
	 * 删除操作，更新del_flag字段
	 *
	 * @param id
	 */
	@Transactional
	public void deleteAcoount(String id) {
			SysClientAccount sysClientAccount = new SysClientAccount();
			sysClientAccount.setId(Integer.parseInt(id));
			sysClientAccount.setDel_flag(1);
			sysClientAccountDao.updateTemplateById(sysClientAccount);
		}



	}



